package jing.filter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class Filter2 implements HandlerInterceptor {

	/*
	 *  在控制器之后执行，一般用于处理异常，日志的处理等
	 */
	public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
			throws Exception {
		System.out.println("filter2      arterCompletion");
	}

	/*
	 *  在控制器返回modelandview之前执行
	 *  一般用于统一显示视图的模板，比如菜单栏等
	 */
	public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
			throws Exception {
		System.out.println("filter2      postHandle");
	}

	/*
	 *  在控制器之前执行，一般用于身份验证，区分用户等级
	 *  返回假，就不会执行控制器了
	 */
	public boolean preHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2) throws Exception {
		System.out.println("filter2      preHandler");
		return true;
	}

}
